package com.vincent.springbucks.entity;

import lombok.*;
import org.hibernate.annotations.Type;
import org.joda.money.Money;

import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * 咖啡实体
 * @author vincent
 * @date 2019/5/12
 * @description
 * Entity表示这是一个jpa实体
 * Table映射数据库中的表
 * ToString需要指定callSuper以把父类中的属性一起打印
 */
@Entity
@Table(name = "T_COFFEE")
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
@Builder
public class Coffee extends BaseEntity implements Serializable {
    /**
     * 咖啡的名称
     */
    private String name;
    /**
     * 价格映射，PersistentMoneyMinorAmount，会以bigint类型存储，一分钱对应值1，66.66元以66660
     */
    @Type(type = "org.jadira.usertype.moneyandcurrency.joda.PersistentMoneyMinorAmount",
            parameters = {@org.hibernate.annotations.Parameter(name = "currencyCode", value = "CNY")})
    private Money price;
}
